package com.tool_stdy.RedisTest.SentitleJedisPool;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by Administrator on 2018/9/8/008.
 */
public class JedisSentinelPoolClient {

    private static final String RedisUrl = "127.0.0.1";

    private JedisSentinelPoolClient() {

    }

    public static class JedisPoolClinetHandler {
        private static final JedisSentinelPool pool = init();
    }

    public static Jedis getClient() {
        return JedisPoolClinetHandler.pool.getResource();
    }


    private static JedisSentinelPool init() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        String masterName = "mymaster";
        Set<String> sentinels = new HashSet<String>();
        sentinels.add("127.0.0.1:6379");
        JedisSentinelPool jedisSentinelPool = new JedisSentinelPool(masterName, sentinels, poolConfig);
        return jedisSentinelPool;
    }

    public static void main(String[] args) {
        JedisSentinelPoolClient.getClient();
    }
}
